/* 代码编辑器样式 */
.code-editor-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 200px;
  background-color: #1e1e1e;
  border-radius: 4px;
  overflow: hidden;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 14px;
  line-height: 1.5;
}

/* 语法高亮层 */
.code-highlight {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px 12px 50px;
  margin: 0;
  background: transparent;
  color: transparent;
  pointer-events: none;
  overflow: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  z-index: 1;
}

/* 实际的文本编辑区域 */
.code-textarea {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  padding: 12px 16px 12px 50px;
  background: transparent;
  color: #d4d4d4;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  white-space: pre-wrap;
  word-wrap: break-word;
  z-index: 2;
  caret-color: #ffffff;
}

.code-textarea::placeholder {
  color: #608b4e;
  font-style: italic;
}

/* 行号显示 */
.line-numbers {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 40px;
  padding: 12px 0;
  background-color: #252526;
  border-right: 1px solid #3e3e42;
  color: #858585;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  user-select: none;
  z-index: 3;
  overflow: hidden;
}

.line-number {
  height: 21px; /* 匹配行高 */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 滚动条样式 */
.code-editor-wrapper ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.code-editor-wrapper ::-webkit-scrollbar-track {
  background: #1e1e1e;
}

.code-editor-wrapper ::-webkit-scrollbar-thumb {
  background: #424242;
  border-radius: 5px;
}

.code-editor-wrapper ::-webkit-scrollbar-thumb:hover {
  background: #4e4e4e;
}

.code-editor-wrapper ::-webkit-scrollbar-corner {
  background: #1e1e1e;
}

/* 语法高亮主题（继承自Prism Tomorrow，但有自定义调整） */
:global(.language-latex) {
  color: #d4d4d4;
}

:global(.language-latex .token.comment) {
  color: #608b4e;
  font-style: italic;
}

:global(.language-latex .token.function) {
  color: #dcdcaa;
}

:global(.language-latex .token.punctuation) {
  color: #d4d4d4;
}

:global(.language-latex .token.operator) {
  color: #d7ba7d;
}

:global(.language-latex .token.number) {
  color: #b5cea8;
}

:global(.language-latex .token.text) {
  color: #ce9178;
}

/* 焦点状态 */
.code-textarea:focus {
  /* 可以添加自定义焦点样式 */
}

/* 选择文本样式 */
.code-textarea::selection {
  background-color: rgba(255, 255, 255, 0.2);
}

.code-textarea::-moz-selection {
  background-color: rgba(255, 255, 255, 0.2);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .code-editor-wrapper {
    font-size: 12px;
    min-height: 150px;
  }
  
  .code-highlight,
  .code-textarea {
    padding-left: 40px;
    padding-right: 12px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  
  .line-numbers {
    width: 32px;
    font-size: 11px;
  }
  
  .line-number {
    height: 18px;
  }
}

/* 无障碍支持 */
.code-textarea {
  aria-label: "LaTeX代码编辑区";
}

/* 打印样式 */
@media print {
  .code-editor-wrapper {
    background: white !important;
    border: 1px solid #ddd !important;
  }
  
  .code-textarea,
  .language-latex {
    color: black !important;
    background: white !important;
  }
  
  .line-numbers {
    background: #f8f8f8 !important;
    border-right: 1px solid #ddd !important;
    color: #666 !important;
  }
}